package wiBase.baseInterface;

import java.util.ArrayList;
import wiBase.WiException;
import wiBase.baseObject.Event;
import wiBase.baseObject.Node;
import wiBase.baseObject.Packet;
import wiBase.baseObject.WiNetwork;

public interface OnEngineListener {
    // controller

    /**
     * start simulation from 0 to duration
     */
    public void run();

    /**
     * start simulation from startTime to endTime
     *
     * @param startTime, endTime (unit: second)
     */
    public void run(long startTime, long endTime);

    /**
     * pause simulation.
     */
    public void pause();

    /**
     * resume simulation.
     */
    public void resume() throws WiException;

    /**
     * stop simulation.
     *
     * @throws WiException if cannot stop.
     */
    public void stop() throws WiException;

    // setting
    /**
     * set value second of start Time
     */
    public void setStartTime(long time);

    /**
     * set value second of finish Time
     */
    @Deprecated
    public void setEndTime(long time);

    /**
     * set speed simulation
     */
    @Deprecated
    public void setSpeed(double speed);

    // for view interact
    /**
     * add an output of Graphics.
     */
    public void addOnDrawerListener(OnDrawerListener listener);
    /**
     * remove all listeners of Graphics.
     */
    public void removeDrawerListener();

    // get info network
    
    /**
     * @return current speed
     */
    @Deprecated
    public double getSpeed();

    /**
     * @return array list of nodes which have idNodes
     * @param idNodes: index of nodes
     */
    public ArrayList<Node> getListNodes(Integer... idNodes);
    /**
     * @return array list of packets which have idPackets
     * @param idPackets: index of packets
     */
    public ArrayList<Packet> getListPackets(Integer... idPackets);
    /**
     * @return array list of events which from startTime to endTime
     * @param idPackets: index of packets
     */
    public ArrayList<Event> getListAllEvents(long startTime, long endTime);
    /**
     * trace a packet which have id=idPacket.
     * @return listEvent relate with that packet.
     * @param idPacket: index of packet
     */
    public ArrayList<Event> tracePacket(int idPacket);
    /**
     * get WiNetwork object recent time (second).
     */
    public WiNetwork printCurrentNetwork(long time);
    /**
     * get Node have idNode
     */
    public Node getNode(int idNode);
    /**
     * @return array list of event relate with node have id=idNode
     */
    public ArrayList<Event> getNodeEvent(int idNode);
    /**
     * @return array list of event relate with packet have id=idPacket
     */
    public Packet getPacket(int idPacket);

    // I/O configuration
    public void setTraceFile(String tracePath);

    public void parse() throws WiException;

    public boolean isParsed();

    public boolean isPlay();

    public boolean isStop();
}
